var t = getApp();

Page({
    data: {
        certificates: "",
        explain_that: "",
        plugin_name: "",
        integral: ""
    },
    onLoad: function(t) {
        this.getData();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    onRead: function() {
        var e = this, a = t.getNetAddresss("upload.uploadPic");
        wx.chooseImage({
            count: 1,
            sizeType: [ "original", "compressed" ],
            sourceType: [ "album", "camera" ],
            success: function(t) {
                var n = t.tempFilePaths;
                wx.compressImage({
                    src: n[0],
                    quality: 60,
                    success: function(t) {
                        var n = t.tempFilePath;
                        wx.uploadFile({
                            url: a,
                            filePath: n,
                            name: "file",
                            success: function(t) {
                                var a = JSON.parse(t.data);
                                1 == a.result ? e.setData({
                                    certificates: a.data.img_url
                                }) : wx.showToast({
                                    icon: "none",
                                    title: a.msg,
                                    duration: 1500
                                });
                            }
                        });
                    },
                    fail: function(t) {},
                    complete: function(t) {}
                });
            }
        });
    },
    getData: function() {
        var e = this, a = t.getNetAddresss("plugin.integral.Frontend.Controllers.recharge.display");
        t._getNetWork({
            url: a,
            success: function(t) {
                var a = t.data;
                1 == a.result ? (e.setData({
                    explain_that: a.data.explain_that,
                    plugin_name: a.data.plugin_name
                }), a.data.plugin_name && wx.setNavigationBarTitle({
                    title: a.data.plugin_name
                })) : wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    confirm: function() {
        if (this.data.certificates) if (this.data.integral) if (this.data.integral <= 0) wx.showToast({
            icon: "none",
            title: "充值积分必须大于0",
            duration: 1500
        }); else {
            var e = {
                certificates: this.data.certificates,
                integral: this.data.integral
            }, a = t.getNetAddresss("plugin.integral.Frontend.Controllers.recharge.recharge");
            t._getNetWork({
                url: a,
                data: e,
                success: function(t) {
                    var e = t.data;
                    1 == e.result ? wx.navigateBack({
                        delta: 1,
                        complete: function() {
                            wx.showToast({
                                icon: "none",
                                title: "充值成功",
                                duration: 1500
                            });
                        }
                    }) : wx.showToast({
                        icon: "none",
                        title: e.msg,
                        duration: 1500
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        } else wx.showToast({
            icon: "none",
            title: "请填写充值积分",
            duration: 1500
        }); else wx.showToast({
            icon: "none",
            title: "请上传充值凭证",
            duration: 1500
        });
    },
    integralChange: function(t) {
        var e = t.detail;
        console.log(e), this.setData({
            integral: e.value
        });
    }
});